package face.pay.web.enterprise.controller.user;

import face.pay.constant.RoleCode;
import face.pay.constant.UserType;
import face.pay.entity.UserInfo;
import face.pay.security.exception.BaseException;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import face.pay.web.user.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: zkj
 * @Date: 2019/7/10 11:26
 * @Description:商家用户管理
 */
@Controller
@RequestMapping(value = "/enterprise_user")
public class EnterpriseUserController {


    @Autowired
    IUserService iUserService;
    /**
     * 企业 商家用户
     * @return
     */
    @RequestMapping("/list")
    public String manager(){

        return  "enterprise/userList";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public ResultMessage editUser(UserInfo userInfo) throws BaseException {

        /**
         * 设置默认的类型
         */
        userInfo.setType(UserType.ENTERPRISE);
        userInfo.setDeleted(0);
        return  iUserService.editUser(RoleCode.ROLE_ENTERPRISE_MANAGER,userInfo);

    }


    @RequestMapping("/queryData")
    @ResponseBody
    public PageData data(PageParam pageParam, UserInfo userInfo) throws BaseException {

        userInfo.setType(UserType.ENTERPRISE);
        userInfo.setDeleted(0);
        return  this.iUserService.queryPage(userInfo,pageParam);

    }

}
